package cc.comac.mom.util.encodedecode;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class Base64Util {

    //加密
    public static String encode(String str){
        return Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8));
    }

    //解密
    public static String decode(String str){
        String decode = new String(Base64.getDecoder().decode(str), StandardCharsets.UTF_8);
        return decode;
    }

    public static void main(String[] args) {
        System.out.print(Base64Util.encode("PITEST:comac123"));
        System.out.print(Base64Util.decode("UElURVNUOmNvbWFjMTIz"));
    }
}
